package cn.xuanxuanyuhua.crm.domain;

import cn.xuanxuanyuhua.crm.util.JSONUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class Customer extends BaseDomain{
    public static final Integer NORMAL = 0;
    public static final Integer POOL = 1;
    public static final Integer FAIL = 2;
    public static final Integer LOSS = 3;

    private String name;

    private Integer age;

    private Integer gender;

    private String tel;

    private String qq;

    private SystemDictionaryItem job;

    private SystemDictionaryItem source;

    private Employee seller;

    private Employee inputUser;

    private Date inputTime;

    private Integer status;

    public String getJson() throws JsonProcessingException {
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("age",age);
        map.put("gender",gender);
        map.put("tel",tel);
        map.put("qq",qq);
        map.put("jobId",job.getId());
        map.put("sourceId",source.getId());
        map.put("sellerName",seller.getName());
        map.put("sellerId",seller.getId());
        map.put("status",status);
        return JSONUtil.toJSONString(map);
    }

    public String getGenderName(){
        String genderName = "男";
        if(gender == 0){
            genderName = "女";
        }
        return genderName;
    }

    public String getStatusName(){
        String statusName = "潜在客户";
        if(status == 1){
            statusName = "客户池";
        }
        if(status == 2){
            statusName = "开发失败";
        }else if(status ==  3){
            statusName = "流失";
        }
        return statusName;
    }
}